package com.example.ibsp_demo.service.impl;

import com.example.ibsp_demo.mapper.content.ContentMapper;
import com.example.ibsp_demo.mapper.content.FavoriteMapper;
import com.example.ibsp_demo.mapper.message.FollowNotificationMapper;
import com.example.ibsp_demo.mapper.message.UserFeedbackMapper;
import com.example.ibsp_demo.mapper.user.UserMapper;
import com.example.ibsp_demo.mapper.user.UserProfileMapper;
import com.example.ibsp_demo.pojo.dto.perCenter.UserProfileDto;
import com.example.ibsp_demo.pojo.entity.content.Content;
import com.example.ibsp_demo.pojo.entity.content.Favorite;
import com.example.ibsp_demo.pojo.entity.message.FollowNotification;
import com.example.ibsp_demo.pojo.entity.message.UserFeedback;
import com.example.ibsp_demo.pojo.entity.user.User;
import com.example.ibsp_demo.pojo.entity.user.UserProfile;
import com.example.ibsp_demo.service.PerCenterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PerCenterServiceImpl implements PerCenterService {

    @Autowired
    private ContentMapper contentMapper;

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private UserProfileMapper userProfileMapper;


    @Autowired
    private FollowNotificationMapper followRelationMapper;

//    @Autowired
//    private ViewRecordMapper viewRecordMapper;

    @Autowired
    private FavoriteMapper favoriteMapper;

    @Autowired
    private UserFeedbackMapper userfeedbackMapper;

//    @Autowired
//    private ActivityOverviewMapper activityOverviewMapper;

    // 1. 查看全部帖子
    @Override
    public List<Content> getAllPostsByAuid(Integer auid) {
        return contentMapper.findByAuid(auid);
    }

    // 2. 编辑个人资料
    @Override
    public boolean updateProfile(UserProfileDto dto) {
        userMapper.updateByUserProfileDto(dto);
        userProfileMapper.updateByUserProfileDto(dto);
        return true;
    }

    // 3. 粉丝列表
    @Override
    public List<FollowNotification> getFollowers(Integer uid) {
        return followRelationMapper.selectFans(uid);
    }

    // 4. 浏览记录
//    @Override
//    public void recordView(Integer uid, Integer ctid) {
//        viewRecordMapper.save(uid, ctid);
//    }

    // 5. 收藏列表
    @Override
    public List<Favorite> getFavorites(Integer uid) {
        return favoriteMapper.selectByUid(uid);
    }

    // 6. 注销账户
    @Override
    public void deactivateUser(Integer uid) {
        userMapper.updateUserStatus(uid, 3);
    }

    // 7. 提交反馈
    @Override
    public void submitFeedback(UserFeedback userfeedback) {
        userfeedbackMapper.insert(userfeedback);
    }

    // 8. 隐私设置
    @Override
    public void updatePrivacySettings(UserProfile profile) {
        userProfileMapper.update(profile);
    }

    @Override
    public UserProfile getProfile(Integer uid) {
        return userProfileMapper.selectByUid(uid);
    }

//    // 9. 活跃概况
//    @Override
//    public ActivityOverview getActivityOverview(Integer uid) {
//        return activityOverviewMapper.findByUid(uid);
//    }
}